home *** CD-ROM | disk | FTP | other *** search
-
- const
- JAN = 1; DEC = 12;
- WEEKS_PER_MONTH = 6;
- SUN = 1; SAT = 7;
-
- type
- monthly_calendar =
- array [1..WEEKS_PER_MONTH, SUN..SAT] of integer;
- annual_calendar
- = array [JAN..DEC] of monthly_calendar;
-
- {*
- * write a monthly calendar
- *}
- procedure write_monthly(var cal : monthly_calendar);
- var
- d, w : integer;
- begin
- for w := 1 to WEEKS_PER_MONTH do
- begin
- for d := SUN to SAT do
- if cal[w, d] > 0 then
- write(cal[w, d]:4)
- else
- write(' ':4);
- writeln;
- end;
- end;
-
- {*
- * return the number of week days in a month
- *}
- function monthly_week_days(var cal : monthly_calendar)
- : integer;
- var
- d, w, sum : integer;
- begin
- sum := 0;
- for w := 1 to WEEKS_PER_MONTH do
- for d := SUN + 1 to SAT - 1 do
- if cal[w, d] > 0 then
- sum := sum + 1;
- monthly_week_days := sum;
- end;
-
- Listing 1 - Calendars in Pascal using Constants
-
-